/****************************************************************************
 * Filename : video-text.h
 * Date     : 14-11-2010
 *
 * Copyright (C) 2010  João Fernandes, Renato Rodrigues
 *
 * This file is part of Bubblecraft.
 *
 * Bubblecraft is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Bubblecraft is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************/
 
#ifndef _VIDEO_TEXT_H_
#define _VIDEO_TEXT_H_

#include "utypes.h"

/** @defgroup VIDEO_TEXT VIDEO_TEXT
 * @{
 *
 * Este módulo contém as funções utilizadas no início do programa, ao mostrar a licença em modo de texto.
 */

/*
 * Definições do ecrã e da memória de vídeo no modo de texto.
 */
#define VIDEO_TEXT  0xB8000 /* Video address in text mode */
#define WIDTH       80      /* Number of columns          */
#define HEIGHT      25      /* Number of rows             */



/* 
 * Cores
 */
#define STRONG      (1 << 3) /* Foreground intensity bit  */
//#define BLINK       (1 << 7) /* Blink bit                 */

#define BLACK           0
#define BLUE            (1 << 0) /* Foreground blue bit       */
#define GREEN           (1 << 1) /* Foreground green bit      */
#define RED             (1 << 2) /* Foreground red bit        */
#define CYAN            (      BLUE | GREEN       )
#define MAGENTA         (       RED | BLUE        )
#define BROWN           (       RED | GREEN       )
#define LIGHT_GRAY      (       RED | GREEN | BLUE)
#define DARK_GRAY       (     WHITE | STRONG      )
#define LIGHT_BLUE      (      BLUE | STRONG      )
#define LIGHT_GREEN     (     GREEN | STRONG      )
#define LIGHT_CYAN      (      CYAN | STRONG      )
#define LIGHT_RED       (       RED | STRONG      )
#define LIGHT_MAGENTA   (   MAGENTA | STRONG      )
#define YELLOW          (     BROWN | STRONG      )
#define WHITE           (LIGHT_GRAY | STRONG      )

#define BLUE_BACK       (1 << 4) /* Background blue bit       */
#define GREEN_BACK      (1 << 5) /* Background gren bit       */
#define RED_BACK        (1 << 6) /* Background red bit        */
#define LIGHT_GRAY_BACK (RED_BACK | GREEN_BACK | BLUE_BACK)

/**
 * Valida as coordenadas x, y consoante os parâmetros da consola.
 */
inline bool_t isValidCoordinate(int x, int y);

/**
 * Mostra o carácter ch na posição x, y com os atributos attributes.
 * Devolve true se bem-sucedido.
 */
bool_t printCharAt(char ch, int x, int y, byte_t attributes);

/**
 * Preenche o ecrã com o carácter ch com os atributos attributes.
 */
void fillScreen(char ch, byte_t attributes);

/**
 * Limpa o ecrã, preenchendo-o com espaços (' ') com o atributo NORMAL.
 * Para tal, a função faz uso da função fillScreen.
 */
void clearScreen();

/**
 * Mostra a array de caracteres str na posição x, y com os atributos
 * attributes.
 * Devolve true se bem-sucedido.
 */
bool_t printStringAt(char *str, int x, int y, byte_t attributes);

/**
 * Mostra o inteiro num na posição x, y com os atributos attributes.
 * Devolve true se bem-sucedido.
 */
bool_t printIntAt(int num, int x, int y, byte_t attributes);

/**
 * Desenha uma moldura rectangular com o canto superior esquerdo
 * posicionado nas coordenadas x, y, com dimensões width e height,
 * decorada com um título title e atributos attributes.
 * Devolve true se bem-sucedido.
 */
bool_t drawFrame(char *title, byte_t attributes, int x, int y, int width, 
               int height);

/** @} End of VIDEO_TEXT */
			   
#endif
